package com.ruoyi.back.service.impl

import com.ruoyi.app.common.*
import com.ruoyi.app.service.AliApiService
import com.ruoyi.app.service.SegmentCommonImageDto
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

@Service
class AliApiServiceImpl : AliApiService {

    @Autowired
    private lateinit var netUrlUploadOss: NetUrlUploadOss


    override fun addSegmentCommonImage(segmentCommonImageDto: SegmentCommonImageDto): Data<String> = try {
        Sign.addSegmentCommonImage(segmentCommonImageDto.imageURL?.trans(), segmentCommonImageDto.returnForm)
            .run {
                Ok("制作成功", netUrlUploadOss.upload(this))
            }
    }catch (e: Exception) {
        throw e
    }
}